import 'package:flutter/material.dart';
import 'package:hook_up_rent/pages/home/widgets/recommend_item.dart';

class HomeRecommendItem {
  final String title;
  final String subTitle;
  final String imageUri;
  final String navigateUri;

  const HomeRecommendItem(
      this.title, this.subTitle, this.imageUri, this.navigateUri);
}

const List<HomeRecommendItem> homeRecommendData = [
  const HomeRecommendItem(
      '家住回龙观', '归属的感觉', 'static/images/home_index_recommend_1.png', 'login'),
  const HomeRecommendItem(
      '宜居四五环', '大都市生活', 'static/images/home_index_recommend_2.png', 'login'),
  const HomeRecommendItem(
      '喧嚣三里屯', '繁华的背后', 'static/images/home_index_recommend_3.png', 'login'),
  const HomeRecommendItem(
      '比邻十号线', '地铁心连心', 'static/images/home_index_recommend_4.png', 'login'),
];

class HomeRecommend extends StatelessWidget {
  final List<HomeRecommendItem> dataList;

  const HomeRecommend({Key key, this.dataList = homeRecommendData}) : super(key: key);


  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.all(5),
      decoration: BoxDecoration(color: Color(0x08000000)),
      child: Column(
        children: [
          _buildRecommendHeader(context),
          Padding(padding: EdgeInsets.all(5)),
          _buildRecommendBody(context)
        ],
      ),
    );
  }

  _buildRecommendHeader(BuildContext context){
    return Container(
      width: MediaQuery.of(context).size.width - 10.0 * 3,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Text("房屋推荐",style: TextStyle(fontSize: 18,fontWeight: FontWeight.w600),),
          Text("更多",style: TextStyle(fontSize: 18,color: Colors.black54),)
        ],
      ),
    );
  }
  _buildRecommendBody(BuildContext context){
    return Wrap(
      runSpacing: 10,
      spacing: 10,
      children: dataList.map((item) => RecommendItem(item)).toList()
    );
  }
}

